/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nvTraces;

import java.util.Enumeration;
import java.util.Hashtable;
import nvOrganism.nvOrganismMgr;
import org.nViron.nvCommon.nvStateMgr;
import org.nViron.nvRender.nvRenderer;
import org.nViron.nvSim.nvSimulator;

/**
 *
 * @author Roland
 */
public class nvTracesMgr extends nvOrganismMgr {

    private Hashtable traces = new Hashtable();

    public nvTracesMgr(nvSimulator simulator) {
        super(simulator);
    }

    @Override
    public void render(nvRenderer renderer) {
        for (Enumeration e = traces.keys(); e.hasMoreElements();)
        {
            nvTrace trace = (nvTrace)traces.get(e.nextElement());
            trace.render(renderer);
        }
    }

    @Override
    public void update() {
        for (Enumeration e = traces.keys(); e.hasMoreElements();)
        {
            Object key = e.nextElement();
            nvTrace trace = (nvTrace)traces.get(key);
            if (trace.getStateMgr().getState() == nvStateMgr.DEAD) {
                traces.remove(key);
            } else {
                trace.update();
            }
        }
    }
}
